The Purpose of This Independent Project

Character Traits

Breed Groups

Load the Libraries

library(plotly)
library(here)
library(tidyverse)
library(ggplot2)
library(dplyr)
library(magick)
library(tidytext)

Read in the Data

Breed_Traits_ <- read_csv(here("Data","Breed Traits .csv")) # Load first data set

View(Breed_Traits_)


AKC_Breed_Info <- read_csv(here("Data","AKC Breed Info.csv")) # Load second data set 

View(AKC_Breed_Info)

Pivot Data Long

long <- Breed_Traits_ %>%
 pivot_longer(cols = c(`Affectionate With Family`,`Good With Young Children`, `Good With Other Dogs`, `Shedding Level`, `Coat Grooming Frequency`, `Drooling Level`, `Openness To Strangers`, `Playfulness Level`, `Watchdog/Protective Nature`, `Adaptability Level`, `Trainability Level`, `Energy Level`, `Barking Level`, `Mental Stimulation Needs`),
              names_to = 'Traits',
              values_to = 'Values') 
View(long)

Create Bar Plot: Character traits measured by Breed Group

Traits_long <- long %>%
  plot_ly(x = ~ `Breed Group`,
          y = ~ Values,
          color = ~ Traits,
          type = "bar",
          marker = list(color = rainbow(nrow(long)))) %>%
  layout(title = 'Breed vs. Traits',
         font = list(color = "darkorchid"),
       plot_bgcolor = "white",
       paper_bgcolor = "lavender",
       xaxis = list(title = 'Breed Group',
                    tickangle = -45,
                    color = "darkorchid"),
       yaxis = list(title = 'Rank',
                    color = "darkorchid"),
       legend = list(title = list(text = '<b> Traits </b>',
                                  font = list(color = "darkorchid"),
                                  xanchor = 'center',
                                  yanchor = 'top')))



Traits_long

Filter Data To Visualize Coat Length

coat_filtered <- Breed_Traits_ %>%
  filter(`Breed Group` %in% c("Hound","Sporting")) %>%
  filter(`Coat Type` %in% c("Smooth","Double"))%>%
  filter(Breed %in% c("Black and Tan Coonhounds","English Foxhounds","Pointers (German Shorthaired)","Greyhounds","Retrievers (Labrador)","Pharaoh Hounds","Redbone Coonhounds","Rhodesian Ridgebacks","Vizslas"))
  
  
View(coat_filtered)

Scatter Plot: Coat Type for Certain Breeds

coat <- coat_filtered  %>%
plot_ly(x = ~ Breed,
          y = ~ `Coat Type`,
          type = "scatter",
        mode = "markers",
        color = ~ Breed,
        colors = "Paired",
        size = 20,
        alpha = 0.5) %>%
layout(title = 'Breed vs. Coat',
         font = list(color = "navy"),
       plot_bgcolor = "white",
       paper_bgcolor = "lightcyan",
       xaxis = list(title = 'Breed Group',
                    tickangle = -45,
                    color = "navy"),
       yaxis = list(title = 'Rank',
                    color = "navy"),
       legend = list(title = list(text = '<b> Traits </b>',
                                  font = list(color = "navy"),
                                  xanchor = 'center',
                                  yanchor = 'top')))
          
 coat

Filter Data To Visualize Weight

weight_f <- AKC_Breed_Info %>%
  drop_na() %>%
  filter(Breed %in% c("Whippet","Vizsla","Rhodesian Ridgeback","Labrador Retriever","German Shorthaired Pointer","Pharaoh Hound","Harrier","English Foxhound","Black And Tan Coonhound","Basset Hound","Beagle","Dachshund","Brittany","Weimarener","Bloodhound","Whippet","Basenji","Pointer","Greyhound","Redbone Coonhound")) %>%
  filter(weight_low_lbs >= 45) %>%
  filter(weight_high_lbs <= 100)
  
  

View(weight_f)

Scatter Plot: Weight for Certain Breeds

weight <- weight_f %>%
  plot_ly(x = ~ weight_low_lbs,
          y = ~weight_high_lbs,
          type = "scatter",
          mode = "markers",
          color = ~Breed,
          colors = "Paired",
          size = 22,
          alpha = 1) %>%
layout(title = 'Breed vs. Weight',
         font = list(color = "navy"),
       plot_bgcolor = "white",
       paper_bgcolor = "lightcyan",
       xaxis = list(title = 'Low Weight Range',
                    tickangle = -45,
                    color = "navy"),
       yaxis = list(title = 'High Weight Range',
                    color = "navy"),
       legend = list(title = list(text = '<b> Breed </b>',
                                  font = list(color = "navy"),
                                  xanchor = 'center',
                                  yanchor = 'top')))

weight

Filter Data For Adaptability and Trainability

trait_filter <- long %>%
  filter(Breed %in% c("Black and Tan Coonhounds","English Foxhounds","Pointers (German Shorthaired)","Greyhounds","Retrievers (Labrador)","Pharaoh Hounds","Redbone Coonhounds","Rhodesian Ridgebacks","Vizslas")) %>%
  filter(Traits %in% c("Trainability Level","Adaptability Level","Good With Other Dogs","Affectionate With Family"))

View(trait_filter)

Bar Plot: Final Filtered Breeds by Adaptability and Trainability

final <- trait_filter %>%
  plot_ly(x = ~ Traits,
          y = ~Values,
          type = "bar",
          mode = "markers",
          color = ~Breed,
          colors = "Dark2") %>%
  layout(title = 'Vizsla vs. Greyhounds',
         font = list(color = "darkred"),
       plot_bgcolor = "white",
       paper_bgcolor = "bisque",
       xaxis = list(title = 'Traits',
                    tickangle = -45,
                    color = "darkred"),
       yaxis = list(title = 'Rank',
                    color = "darkred"),
       legend = list(title = list(text = '<b> Breed </b>',
                                  font = list(color = "darkred"),
                                  xanchor = 'center',
                                  yanchor = 'top')))


final

Image of The Winner

Vizsla <- image_read("https://images.ctfassets.net/m5ehn3s5t7ec/wp-image-198422/0e0fe308ed17ab3af5f3c8f2db288667/Vizsla-Dog-Breed-Information.jpg") 

image_border(Vizsla, color = "peachpuff", geometry = "8x10")

image_annotate(Vizsla, "Vizsla", size = 75, gravity = "southwest", color = "black", boxcolor = "white")

Vizsla